package com.red.basic.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.red.common.annotation.Log;
import com.red.common.core.controller.BaseController;
import com.red.common.core.domain.AjaxResult;
import com.red.common.enums.BusinessType;
import com.red.basic.domain.RedCustomFolder;
import com.red.basic.service.IRedCustomFolderService;
import com.red.common.utils.poi.ExcelUtil;

/**
 * 客户文件夹Controller
 * 
 * @author ruoyi
 * @date 2024-11-10
 */
@RestController
@RequestMapping("/basic/customFolder")
public class RedCustomFolderController extends BaseController
{
    @Autowired
    private IRedCustomFolderService redCustomFolderService;

    /**
     * 查询客户文件夹列表
     */
    @PreAuthorize("@ss.hasPermi('basic:customFolder:list')")
    @GetMapping("/list")
    public AjaxResult list(RedCustomFolder redCustomFolder)
    {
        List<RedCustomFolder> list = redCustomFolderService.selectRedCustomFolderList(redCustomFolder);
        return success(list);
    }

    /**
     * 导出客户文件夹列表
     */
    @PreAuthorize("@ss.hasPermi('basic:customFolder:export')")
    @Log(title = "客户文件夹", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RedCustomFolder redCustomFolder)
    {
        List<RedCustomFolder> list = redCustomFolderService.selectRedCustomFolderList(redCustomFolder);
        ExcelUtil<RedCustomFolder> util = new ExcelUtil<RedCustomFolder>(RedCustomFolder.class);
        util.exportExcel(response, list, "客户文件夹数据");
    }

    /**
     * 获取客户文件夹详细信息
     */
    @PreAuthorize("@ss.hasPermi('basic:customFolder:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(redCustomFolderService.selectRedCustomFolderById(id));
    }

    /**
     * 新增客户文件夹
     */
    @PreAuthorize("@ss.hasPermi('basic:customFolder:add')")
    @Log(title = "客户文件夹", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RedCustomFolder redCustomFolder)
    {
        return toAjax(redCustomFolderService.insertRedCustomFolder(redCustomFolder));
    }

    /**
     * 修改客户文件夹
     */
    @PreAuthorize("@ss.hasPermi('basic:customFolder:edit')")
    @Log(title = "客户文件夹", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RedCustomFolder redCustomFolder)
    {
        return toAjax(redCustomFolderService.updateRedCustomFolder(redCustomFolder));
    }

    /**
     * 删除客户文件夹
     */
    @PreAuthorize("@ss.hasPermi('basic:customFolder:remove')")
    @Log(title = "客户文件夹", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(redCustomFolderService.deleteRedCustomFolderByIds(ids));
    }
}
